<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/*$subject
      http://bitonsoccer.com/mail/sendmail?mail={$mail}&subject={$subject}&template={$template}&data[user]={$ser}
      template = activateAccount
  */

function sendEmail($data, $mail, $template, $subject) {
    $params = "mail={$mail}&subject={$subject}&template={$template}";
    foreach ($data as $key => $value) {
        $params .= "&data[{$key}]={$value}";
    }

    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, "http://bitonsoccer.com/mail/sendmail");
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
    // Tell curl not to return headers, but do return the response
    curl_setopt($ch, CURLOPT_HEADER, false);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    $response = curl_exec($ch);
    curl_close($ch);
    // print everything out
    print_r($response);
}
